// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "Hidden/TerrainEngine/BillboardTree" {
Properties {
 _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" { }
}
SubShader { 
 Tags { "QUEUE"="Transparent-100" "IGNOREPROJECTOR"="true" "RenderType"="TreeBillboard" }
 Pass {
  Tags { "QUEUE"="Transparent-100" "IGNOREPROJECTOR"="true" "RenderType"="TreeBillboard" }
  ZWrite Off
  Cull Off
  Blend SrcAlpha OneMinusSrcAlpha
  ColorMask RGB
  GpuProgramID 27539
CGPROGRAM
//#pragma target 4.0

#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"


#define CODE_BLOCK_VERTEX
//uniform float4x4 UNITY_MATRIX_MVP;
uniform float3 _TreeBillboardCameraRight;
uniform float4 _TreeBillboardCameraUp;
uniform float4 _TreeBillboardCameraFront;
uniform float4 _TreeBillboardCameraPos;
uniform float4 _TreeBillboardDistances;
uniform sampler2D _MainTex;
struct appdata_t
{
    float4 vertex :POSITION;
    float4 color :COLOR;
    float4 texcoord :TEXCOORD0;
    float4 texcoord1 :TEXCOORD1;
};

struct OUT_Data_Vert
{
    float4 xlv_COLOR0 :COLOR0;
    float2 xlv_TEXCOORD0 :TEXCOORD0;
    float4 vertex :SV_POSITION;
};

struct v2f
{
    float4 xlv_COLOR0 :COLOR0;
    float2 xlv_TEXCOORD0 :TEXCOORD0;
};

struct OUT_Data_Frag
{
    float4 color :SV_Target0;
};

OUT_Data_Vert vert(appdata_t in_v)
{
    OUT_Data_Vert out_v;
    float4 tmpvar_1;
    tmpvar_1 = in_v.color;
    float4 tmpvar_2;
    tmpvar_2 = in_v.texcoord;
    float2 tmpvar_3;
    float4 pos_4;
    pos_4 = in_v.vertex;
    float2 offset_5;
    offset_5 = in_v.texcoord1.xy;
    float offsetz_6;
    offsetz_6 = tmpvar_2.y;
    float3 tmpvar_7;
    tmpvar_7 = (in_v.vertex.xyz - _TreeBillboardCameraPos.xyz);
    float tmpvar_8;
    tmpvar_8 = dot(tmpvar_7, tmpvar_7);
    if((tmpvar_8>_TreeBillboardDistances.x))
    {
        offsetz_6 = 0;
        offset_5 = float2(0, 0);
    }
    pos_4.xyz = (in_v.vertex.xyz + (_TreeBillboardCameraRight * offset_5.x));
    pos_4.xyz = (pos_4.xyz + (_TreeBillboardCameraUp.xyz * lerp(offset_5.y, offsetz_6, _TreeBillboardCameraPos.w)));
    pos_4.xyz = (pos_4.xyz + ((_TreeBillboardCameraFront.xyz * abs(offset_5.x)) * _TreeBillboardCameraUp.w));
    tmpvar_3.x = tmpvar_2.x;
    tmpvar_3.y = float((in_v.texcoord.y>0));
    out_v.vertex = UnityObjectToClipPos(pos_4);
    out_v.xlv_COLOR0 = tmpvar_1;
    out_v.xlv_TEXCOORD0 = tmpvar_3;
    return out_v;
}

#define CODE_BLOCK_FRAGMENT
OUT_Data_Frag frag(v2f in_f)
{
    OUT_Data_Frag out_f;
    float4 col_1;
    float4 tmpvar_2;
    tmpvar_2 = tex2D(_MainTex, in_f.xlv_TEXCOORD0);
    col_1.w = tmpvar_2.w;
    col_1.xyz = (tmpvar_2.xyz * in_f.xlv_COLOR0.xyz);
    if((tmpvar_2.w<0))
    {
        discard;
    }
    out_f.color = col_1;
    return out_f;
}


ENDCG

}
}
Fallback Off
}